//
// Copyright (C) [2024] Xingyun Integrated Circuit, Inc.
//
// GreenCode was a private technology asset of Xingyun Integrated Circuit， Inc （Confidential）
//  Author: Shawn.Tan
//  Date : 2025.10.28
//
//  History : Initial Version 2025.10.28
//
//
#ifndef Green_SimplePeState_H
#define Green_SimplePeState_H

#include <vector>

#include "Defines.h"

namespace Green {

  class Generator;
  class Register;

  /*!
    \class SimpleRegisterState
    \brief Simple Register state struct.
  */
  class SimpleRegisterState {
  public:
    explicit SimpleRegisterState(Register* pReg); //!< Constructor.
    SimpleRegisterState() : mpRegister(nullptr), mValue(0) { } //!< Default constructor.
  private:
    Register* mpRegister; //!< Pointer to register object.
    uint64 mValue; //!< Register value.

    friend class SimplePeState;
  };

  /*!
    \class SimplePeState
    \brief Class containing essential simple PE state information for
  */
  class SimplePeState {
  public:
    SimplePeState() : mRegisterStates(), mpGpr(nullptr) { } //!< Default constructor.
    ASSIGNMENT_OPERATOR_ABSENT(SimplePeState);
    COPY_CONSTRUCTOR_DEFAULT(SimplePeState);
    void SaveState(Generator* pGen, const std::vector<Register* >& rRegContext); //!< Save PE state.
    bool RestoreState(); //!< Restore PE state;
  private:
    std::vector<SimpleRegisterState> mRegisterStates;
    Register* mpGpr; //!< Pointer to an useable GPR register.
  };

}

#endif
